package com.ubs.lingua.buildtool.cs.parameters;

import java.io.Serializable;

/**
 * The Lingua C# Build Agent build batch parameters.
 */
public class BuildParameters implements Serializable {

    private static final long serialVersionUID = -6083990942319926340L;

    private final String assemblyName;

    private PackerSettings packerSettings = PackerSettings.MAXIMUM_INTEROP;

    private CscParameters cscParams = new CscParameters();

    /**
     * Constructs a new build batch with the specified assembly name.
     * 
     * @param assemblyName the assembly name.
     *                     The specified name will be used by the C# command line compiler as the name of the assembly to generate.
     */
    public BuildParameters(final String assemblyName) {
        this.assemblyName = assemblyName;
    }

    /**
     * Predefined configurations of the ZIP packer.
     */
    public static enum PackerSettings {
        /**
         * This configuration is the most suitable if java.util.zip is the main archive consumer.
         * The character encoding to use for filenames inside the zip file is set to UTF-8.
         * The language encoding flag is enabled to allow archivers that support it to show the correct file names.
         */
        JAVA,
        /**
         * Maximum interop configuration.
         * The character encoding to use for filenames inside the zip file is set to UTF-8.
         * The language encoding flag is enabled to allow archivers that support it to show the correct file names.
         * Unicode extra fields are created to store the file names a second time inside the entry's metadata. 
         * Such archive should be extracted correctly by java.util.zip, 7Zip, WinZIP, PKWARE tools and most likely InfoZIP tools.
         * They will be unusable with Windows' "compressed folders" feature and bigger than archives without the unicode extra fields, though.
         */
        MAXIMUM_INTEROP,
        /**
         * This configuration is the most suitable if Windows' "compressed folders" is the main archive consumer.
         * The character encoding to use for filenames inside the zip file is set to ISO 8859-1 (Latin Alphabet No. 1).
         * Unicode extra fields are created to store the file names a second time inside the entry's metadata
         * so the tools that support them will extract the file names correctly.
         */
        WINDOWS;
    }

    /**
     * Returns the assembly name.
     * @return the assembly name
     */
    public String getAssemblyName() {
        return assemblyName;
    }

    /**
     * Returns the ZIP packer configuration.
     * The value set at class initialization time is {@link PackerSettings#MAXIMUM_INTEROP}.
     * @return the packer configuration
     */
    public PackerSettings getPackerSettings() {
        return packerSettings;
    }

    /**
     * Sets the ZIP packer configuration that will be returned by {@link #getPackerSettings()}.
     * The value set at class initialization time is {@link PackerSettings#MAXIMUM_INTEROP}.
     * @param packerSettings the packer configuration to be associated with this build batch
     */
    public void setPackerSettings(final PackerSettings packerSettings) {
        this.packerSettings = packerSettings;
    }

    /**
     * Returns the C# command line compiler parameters.
     * @return the C# command line compiler parameters
     */
    public CscParameters getCscParams() {
        return cscParams;
    }

    /**
     * Sets the C# command line compiler parameters that will be returned by {@link #getCscParams()}.
     * @param cscParams the C# command line compiler parameters to be associated with this build batch
     */
    public void setCscParams(final CscParameters cscParams) {
        this.cscParams = cscParams;
    }

}
